// Fill out your copyright notice in the Description page of Project Settings.


#include "EnemyAnimInstance.h"
#include "EnemyCharacter.h"
#include "GameFramework\Pawn.h"
#include "GameFramework\PawnMovementComponent.h"

void UEnemyAnimInstance::NativeInitializeAnimation()
{
	if (!Pawn)
	{
		Pawn = TryGetPawnOwner();
	}
	Enemy = Cast<AEnemyCharacter>(Pawn);
}

void UEnemyAnimInstance::UpdateAnimation()
{
	if (!Pawn)
	{
		Pawn = TryGetPawnOwner();
	}
	else
	{
		FVector Speed = Pawn->GetVelocity();
		FVector LaterialSpeed = FVector(Speed.X, Speed.Y, 0);
		MoveSpeed = LaterialSpeed.Size();
		IsFalling = Pawn->GetMovementComponent()->IsFalling();
	}
}